import { GSprite } from "../../../../com/mui/controls/GSprite";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ItemData } from "../../resource/info/ItemData";
import { EColor } from "../../../../Message/Public/EColor";
import { SpiritEquipStrengthenConfig } from "../../resource/SpiritEquipStrengthenConfig";
import { Language } from "../../../../extend/language/Language";
import { EquipmentItemDataUtil } from "../common/EquipmentItemDataUtil";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { TSpiritEquipStrengthen } from "../../../../Message/Db/Tables/TSpiritEquipStrengthen";
type int = number;
//class StrengthAttributePanel
    
    export /* dynamic */ class StrengthAttributePanel extends GSprite
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public set isStrengthNextLevel(arg1: Boolean)
        {
            this._isStrengthNextLevel = arg1;
            return;
        }

        public get level(): int
        {
            return this._level;
        }

        /* internal  */init(): void
        {
            var loc1=ObjCreate.createBg(0, 0, 140, 168, this);
            this._strengthBmp = ObjCreate.createBitmap(ImagesConst.equipment_strengthen_qianghua, 46, 5, this);
            this._levelTxt = ObjCreate.createGTextField("", 88, 5, 50, 30, this, GlobalStyle.textFormatGreen);
            this._addTxt = ObjCreate.createGTextField("", 0, 25, 140, 20, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat1));
            this._attributeTxt = ObjCreate.createGTextField("", 10, 45, 130, 123, this, GlobalStyle.textFormat6);
            this._attriValue = ObjCreate.createGTextField("", 65, 45, 130, 123, this, GlobalStyle.textFormat6);
            return;
        }

        public updateItemDate(arg1: ItemData): void
        {
            var loc6=0;
            var loc7=null;
            var loc8=NaN;
            this._level = 0;
            if (arg1 && arg1.itemExInfo) 
            {
                this._level = arg1.itemExInfo.sp_eq_str;
            }
            if (this._isStrengthNextLevel) 
            {
                this._level = this._level + 1;
            }
            this._levelTxt.text = "+" + this._level;
            var loc1=arg1.color;
            if (arg1.color != EColor._EColorBlue) 
            {
                loc1 = EColor._EColorPurple;
            }
            this._strengthInfo = null;
            this._strengthInfo = SpiritEquipStrengthenConfig.instance.getSpiritEquipStrengthenInfo(loc1, this._level);
            if (this._strengthInfo) 
            {
                if ((loc8 = this._strengthInfo.percentAdd / 100) > 0) 
                {
                    this._addTxt.text = Language.getString(36633) + "+" + loc8 + "%";
                }
                else 
                {
                    this._addTxt.text = Language.getString(36633) + "+0";
                }
            }
            var loc2=new EquipmentItemDataUtil(arg1);
            var loc3=loc2.getBasePropArray();
            var loc4="";
            var loc5="";
            loc6 = 0;
            while (loc6 < loc3.length) 
            {
                loc7 = loc3[loc6] as Map<any, any> /* flash.utils.Dictionary */;
                loc4 = loc4 + loc7["name"] + "\n";
                loc5 = loc5 + this.getValueString(loc7["value"]) + "+" + Math.ceil(loc7["value"] * loc8 / 100) + "\n";
                ++loc6;
            }
            this._attributeTxt.htmlText = "<textFormat leading=\'5\'>" + loc4 + "</textFormat>";
            this._attriValue.htmlText = "<textFormat leading=\'5\'>" + loc5 + "</textFormat>";
            this._strengthBmp.visible = true;
            return;
        }

        /* internal  */getValueString(arg1: int): string
        {
            var loc1="";
            loc1 = loc1 + arg1;
            if (arg1 < 10) 
            {
                loc1 = loc1 + "     ";
            }
            else if (arg1 < 100) 
            {
                loc1 = loc1 + "    ";
            }
            else if (arg1 < 1000) 
            {
                loc1 = loc1 + "   ";
            }
            else 
            {
                loc1 = loc1 + "  ";
            }
            return loc1;
        }

        public getSpiritCoin(): int
        {
            if (this._strengthInfo) 
            {
                return this._strengthInfo.spiritCoinCost;
            }
            return 0;
        }

        public getCoin(): int
        {
            if (this._strengthInfo) 
            {
                return this._strengthInfo.coinCost;
            }
            return 0;
        }

        public resetShow(): void
        {
            this._strengthBmp.visible = false;
            this._levelTxt.text = "";
            this._addTxt.text = "";
            this._attributeTxt.text = "";
            this._attriValue.text = "";
            return;
        }

        /* internal */ /* var */_levelTxt: GTextFiled;

        /* internal */ /* var */_addTxt: GTextFiled;

        /* internal */ /* var */_attributeTxt: GTextFiled;

        /* internal */ /* var */_attriValue: GTextFiled;

        /* internal */ /* var */_strengthBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_isStrengthNextLevel: Boolean=false;

        /* internal */ /* var */_strengthInfo: TSpiritEquipStrengthen;

        /* internal */ /* var */_level: int;
    }
